package coml.jiyun.hp.wanandroid.model;

import android.util.Log;

import coml.jiyun.hp.wanandroid.base.BaseModel;
import coml.jiyun.hp.wanandroid.bean.BannerBean;
import coml.jiyun.hp.wanandroid.bean.HomeBean;
import coml.jiyun.hp.wanandroid.net.HttpUtil;
import coml.jiyun.hp.wanandroid.net.ResultCallBack;
import coml.jiyun.hp.wanandroid.net.ResultSubscriber;
import coml.jiyun.hp.wanandroid.net.RxUtils;

public class HomeModel extends BaseModel {
    private static final String TAG = "HomeModel";
    public void getHome(final ResultCallBack<HomeBean> callBack) {
        addDisposable(
                HttpUtil.getInstance()
                        .getHomeServer()
                        .getHome()
                        .compose(RxUtils.<HomeBean>rxSchedulerHelper())
                        .subscribeWith(new ResultSubscriber<HomeBean>() {
                            @Override
                            public void onNext(HomeBean homeBean) {
                                callBack.onSuccess(homeBean);
                                Log.d(TAG, "onNext: "+homeBean);
                            }
                        })
        );
    }

    public void getBanner(final ResultCallBack<BannerBean> callBack) {
        addDisposable(HttpUtil.getInstance()
                .getApiServer()
                .getBanner()
                .compose(RxUtils.<BannerBean>rxSchedulerHelper())
                .subscribeWith(new ResultSubscriber<BannerBean>() {
                    @Override
                    public void onNext(BannerBean bannerBean) {
                        callBack.onSuccess(bannerBean);
                    }
                }));
    }
}
